s=input().split()
if len(s)!=3:
    print("Wrong input")
    exit()
try:
    n=int("".join(s))
except ValueError:
    print("Wrong input")
    exit()

if n<100 or n>999:
    print("Wrong input")
    exit()
   
def is_prime(n2):
    if n2<=1:
        return False
    for i in range(2, int(n2**0.5)+1):
        if n2%i==0:
            return False
    return True

nearest_prime=n
while not is_prime(nearest_prime):
    nearest_prime+=1

print(nearest_prime)